<?php
    session_start();
    $caca ='';
    include("language.php");
    include('database.php');
    
    $_SESSION['curPage'] = 'admin.php';
    
    if(isset($_SESSION['connected']) AND $_SESSION['connected'])
    {
        if($_SESSION['access'] != 10)
        {
          header("Location: error.php"); 
        }
        else
        {            
            $query=$db->query("SELECT admin_id, soldTickets, username  FROM tickets INNER JOIN user on admin_id = id");
            
            if(isset($_POST['ticket']))
            {
                //changer car pas bon
              $gagnant= $db->query("SELECT battletag from USER inner join drawparticipation on user_id = id where \"".$_POST['ticket']."\" = ticket_id");
               
                while($data = $gagnant->fetch()) 
               { 
                   $caca =  $data['battletag'];
               }
            }
        }
    }
    else header("Location: error.php"); 
?>
<!DOCTYPE html>
<html>
    <head>
            <meta charset="utf-8" />
            <link rel="stylesheet" href="style.css" />
    </head>
    <body>
        <div class="d_body">
       <?php include('header.php'); ?>
             
        <section id="body">
                <h1>L'administration</h1>
        </section>
            
        
         <br>
         <div class="d_menuBar">
         <ul class="menuBarTable">
           <li><a href="home.php">Accueil</a></li>
           <li><a href="listMember.php">Liste des membres</a></li>
           <li><a href="addTickets.php">Ajout tickets</a></li>
           <li><a href="idTicketByDraw.php">Liste Ticket</a></li>
           </ul>  
       </div> 
           <br><br><br><br>
         
        <?php
        
        $id_Ticket= 0;
       /* echo '<br/><center><table class="listMember">
        
        <th class="td_listerMember">ID_ADMIN</th><th class="td_listerMember">pseudo</th><th class="td_listerMember">SOlD TICKET</th>';
         
         while($data = $query->fetch()) 
         { 
             echo '<tr><td class="td_listerMember">'.$data['admin_id'].'</td>';
             echo '<td class="td_listerMember">'.$data['username'].'</td>';
             echo '<td class="td_listerMember">'.$data['soldTickets'].'</td></tr>';
             
          }   
             echo '</table></center>'; */ 
             
              echo '<br/><br/><br/><center><table class="listMember"><form method=post action="admin.php">
        <th class="td_listerMember">ID_TICKET</th><th class="td_listerMember">ENVOYER</th><tr>';
         
        
             echo '<td><input type=text name="ticket" value='.$id_Ticket.'></td>';
             echo '<td class="td_listerMember"><input type=submit name="id" value="Valider la recherche"></input></td></tr>';
             
          echo '</table></center></form><br/><br/>';
         
          
            if($ok != '')
            {
                echo $ok;
            }


         ?>   
          
          
        </div>
    </body>
</html>
